package com.itlong.cloud.operate.resource;

import com.itlong.cloud.POJO.DTO.operate.OperateProductTypeManageGetDTO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.POJO.VO.operate.OperateAssignProductModelRelationGetVO;
import com.itlong.cloud.POJO.VO.operate.OperateProductTypeManageGetVO;
import com.itlong.cloud.operate.service.IOperateProductTypeManageService;
import com.itlong.cloud.paymenthub.IOperateProductTypeManageServiceClient;
import com.itlong.cloud.utils.page.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-产品类型管理暴露接口实现类
 * </desc>
 *
 * @createDate 2020/12/03
 */
@RestController
public class OperateProductTypeManageServiceResource implements IOperateProductTypeManageServiceClient {

    @Autowired
    private IOperateProductTypeManageService iOperateProductTypeManageService;



    /**
     * <desc>
     *      分页获取任务书产品类型信息
     * </desc>
     *
     * @param dto 获取任务书产品类型信息DTO
     * @return 分页任务书产品类型信息
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/getPage")
    public Page<OperateProductTypeManageGetVO> getPage(@RequestBody OperateProductTypeManageGetDTO operateProductTypeManageGetDTO) throws Exception{
        return iOperateProductTypeManageService.getPage(operateProductTypeManageGetDTO);
    }

    /**
     * <desc>
     *      获取任务书产品类型详情
     * </desc>
     *
     * @param operateProductTypeManageGetDTO 获取任务书产品类型详情DTO
     * @return 任务书产品类型详情
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/getOne")
    public  OperateProductTypeManageGetVO   getOne(@RequestBody OperateProductTypeManageGetDTO operateProductTypeManageGetDTO) throws Exception{
        return iOperateProductTypeManageService.getOne(operateProductTypeManageGetDTO);
    }

    /**
     * <desc>
     *      任务书产品类型信息删除
     * </desc>
     *
     * @param dto 任务书产品类型dto
     * @return 任务书产品类型删除
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/delete")
    public Integer   delete(@RequestBody  OperateProductTypeManageGetDTO  dto)throws Exception{
        return  iOperateProductTypeManageService.delete(dto);
    }

    /**
     * <desc>
     *      添加或者更新产品类型
     * </desc>
     *
     * @param dto 产品类型dto
     * @return
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/saveOrUpdate")
    public MessageVO saveOrUpdate(@RequestBody OperateProductTypeManageGetDTO dto) throws Exception{
        return  iOperateProductTypeManageService.saveOrUpdate(dto);
    }


    /**
     * <desc>
     *      获取产品类型相关产品型号列表
     * </desc>
     *
     * @return 标准格式化响应结果
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/getRelatedProcModelPage")
    public  Page<OperateAssignProductModelRelationGetVO> getRelatedProcModelPage(@RequestBody OperateProductTypeManageGetDTO dto) throws Exception{
        return  iOperateProductTypeManageService.getRelatedProcModelPage(dto);
    }

    /**
     * <desc>
     *      获取产品型号列表
     * </desc>
     *
     * @return 标准格式化响应结果
     * @author pengwei
     * @createDate 2020/12/03
     */
    @PostMapping(path = "/operate/productTypeManage/proModelSearch")
    public Page<OperateAssignProductModelRelationGetVO> getProcModelPage(@RequestBody OperateProductTypeManageGetDTO dto) throws Exception{
        return  iOperateProductTypeManageService.getProcModelPage(dto);
    }

    /**
     * <desc>
     *      获取产品类型下的产品信息列表
     * </desc>
     *
     * @param productType 产品类型 1电梯类2门禁类 3人脸类 4对讲类
     * @return
     * @Author Zhu.yj
     * @createDate  2021/2/22
     */
    @Override
    @PostMapping("/operate/productTypeManage/getAssignmentTypeList")
    public List<Map<String, Object>> getAssignmentTypeList(@RequestParam("productType") String productType) throws Exception {
        return iOperateProductTypeManageService.getAssignmentTypeList(productType);
    }
}
